package cn.trasen.his.poc.std.api.model.inpatient;

import cn.trasen.his.poc.std.api.emums.InfantFlagEnum;
import pro.shushi.pamirs.boot.base.ux.annotation.field.UxWidget;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxDetail;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxForm;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTableSearch;
import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.base.IdModel;

import java.util.List;

/**
 * @Description: 医嘱组管理
 * @author: Jacob
 * @Date: 2024-11-28 14:33:02
 * @Company: 湖南创星科技股份有限公司
 */
// 模型中UX开头的注解(UxForm/UxTable/UxDetail等)可以不用写，都可在设计器中进行可视化配置; 代码里面写这些注解是为了默认页面的交互
@UxForm(grid = 3)
@UxDetail(grid = 3)
@Model.model(MedicationAdvice.MODEL_MODEL)
@Model(displayName = "医嘱处方")
@Model.Advanced(index = {"orgCode", "hospCode"})
public class MedicationAdvice extends IdModel {

    public static final String MODEL_MODEL = "ts.his.OrderGroupManager";

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field.many2one
    @Field.Relation(relationFields = {"visitId"}, referenceFields = {"id"})
    @Field(displayName = "患者姓名", required = true)
    private VisitRecord visitRecord;

    @Field.Integer
    @Field(displayName = "就诊ID", invisible = true)
    private Long visitId;

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field.many2one
    @Field.Relation(relationFields = {"inpatientId"}, referenceFields = {"id"}, domain = "visitId==${activeRecord.visitRecord.id} and status=='2'")
    @Field(displayName = "住院号")
    private InpatientRecord inpatient;

    @Field.Integer
    @Field(displayName = "住院病人ID", invisible = true)
    private Long inpatientId;

    @Field.String
    @Field(displayName = "机构代码")
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field.Related(related = {"visitRecord", "orgCode"})
    private String orgCode;

    @Field.String
    @Field(displayName = "院区代码")
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field.Related(related = {"visitRecord", "hospCode"})
    private String hospCode;

    @Field.String
    @Field(displayName = "病区")
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field.Related(related = {"inpatient", "wardName"})
    private String wardName;

    @Field.Enum
    @Field.Related(related = {"inpatient", "infantFlag"})
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "人员类型")
    private InfantFlagEnum infantFlag;

    @Field.String
    @UxForm.FieldWidget(@UxWidget(readonly = "true", invisible = "activeRecord.infantFlag!='BABY'"))
    @UxDetail.FieldWidget(@UxWidget(invisible = "activeRecord.infantFlag!='BABY'"))
    @Field.Related(related = {"inpatient", "infantNum"})
    @Field(displayName = "婴儿编号")
    private String infantNum;

    @Field.Text
    @UxForm.FieldWidget(@UxWidget(span = 3))
    @UxDetail.FieldWidget(@UxWidget(span = 3))
    @Field(displayName = "诊断")
    private String curDiagnosisName;

    @Field.one2many
    @Field.Relation(relationFields = {"id"}, referenceFields = {"medAdviceId"})
    @Field(displayName = "处方列表", required = true)
    private List<OrderRecord> orderRecords;
}